package leetcode;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * ClassName: XiaohoushuT1
 * Package: leetcode
 * Description:
 *
 * @Author wjn
 * @Create 2025/9/3 19:20
 * @Version 1.0
 */
public class XiaohoushuT1 {
    public static void main(String[] args) {
        int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        int ans = 0;
        for (int p : primes) {
            List<Integer> indices = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if (a[i] % p == 0) {
                    indices.add(i);
                }
            }
            if (indices.isEmpty()) {
                continue;
            }
            int pre2 = 0;
            int pre1 = 1;
            for (int i = 1; i < indices.size(); i++) {
                if (indices.get(i) - indices.get(i - 1) == 1) {
                    int current = Math.max(pre1, pre2 + 1);
                    pre2 = pre1;
                    pre1 = current;
                } else {
                    int current = pre1 + 1;
                    pre2 = pre1;
                    pre1 = current;
                }
            }
            ans = Math.max(ans, pre1);

        }
        System.out.println(ans);
    }
}
